function [img, map, alpha, slim] = fetchskin(name)
id_obj = webread(['https://api.mojang.com/users/profiles/minecraft/' name], weboptions('UserAgent', 'skins-uuid-fetcher'));
assert(isfield(id_obj, 'id') && ischar(id_obj.id), 'Invalid response (id_obj.id is not a string)');
info_obj = webread(['https://sessionserver.mojang.com/session/minecraft/profile/' id_obj.id '?unsigned=false']);
assert(~isfield(info_obj, 'error'), 'Invalid response (info_obj.error exists)');
assert(isfield(info_obj, 'properties'), 'Invalid response (info_obj.properties is missing)');
texture_obj = [];
for prop = info_obj.properties
    if isfield(prop, 'name') && strcmpi(prop.name, 'textures')
        assert(isfield(prop, 'value') && ischar(prop.value), 'Invalid response (info_obj.properties[].value is not a string)');
        texture_obj = jsondecode(native2unicode(matlab.net.base64decode(prop.value)));
        break;
    end
end
assert(isfield(texture_obj, 'textures'), 'Invalid response (texture_obj.textures is missing)');
assert(isfield(texture_obj.textures, 'SKIN'), 'Invalid response (texture_obj.textures.SKIN is missing)');
skin_obj = texture_obj.textures.SKIN;
assert(isfield(skin_obj, 'url') && ischar(skin_obj.url), 'Invalid response (texture_obj.textures.SKIN.url is not a string)');
slim = isfield(skin_obj, 'metadata') && isfield(skin_obj.metadata, 'model') && strcmp(skin_obj.metadata.model, 'slim');
[img, map, alpha] = imread(skin_obj.url, 'png');
end
